<template>
    <scroll id="CategoryMenu">
        <div class="menu-list">
            <div class="menu-list-item" v-for="(item,index) in categoryList" :key="index"
                :class="{'active':index===currentIndex}" @click="itemClick(index)">
                {{item.title}}
            </div>
        </div>
    </scroll>
</template>

<script>
import Scroll from 'common/scroll/Scroll'
export default {
    name: "CategoryMenu",
    props: {
        categoryList: {
            type: Array
        }
    },
    components: {
        Scroll
    },
    data () {
        return {
            currentIndex: ''
        }
    },
    methods: {
        itemClick (index) {
            this.currentIndex = index
            this.$emit('selectItem', index)
        }
    }
}
</script>

<style scoped>
#CategoryMenu {
    background-color: #f6f6f6;
    height: 100%;
    width: 100px;
    box-sizing: border-box;
}

.menu-list-item {
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 14px;
}
.active {
    font-weight: 700;
    color: var(--color-high-text);
    background-color: #fff;
    border-left: 3px solid var(--color-high-text);
}
</style>